#include "ColorWidget.h"
#include "ui_ColorWidget.h"

ColorWidget::ColorWidget(const QColor &cr,QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ColorWidget)
{
    ui->setupUi(this);

    color = cr;

    init();
}

ColorWidget::~ColorWidget()
{
    delete ui;
}

QColor ColorWidget::GetColor()
{
    return color;
}

void ColorWidget::init()
{
    if(color == COLORS::COLOR_Black)
        on_Button_Black_clicked();
    else if(color == COLORS::COLOR_Gray)
        on_Button_Gray_clicked();
    else if(color == COLORS::COLOR_Green)
        on_Button_Green_clicked();
    else if(color == COLORS::COLOR_Red)
        on_Button_Red_clicked();
    else if(color == COLORS::COLOR_Orangle)
        on_Button_Orangle_clicked();
    else if(color == COLORS::COLOR_White)
        on_Button_White_clicked();
    else if(color == COLORS::COLOR_Blue)
        on_Button_Blue_clicked();
    else if(color == COLORS::COLOR_Purple)
        on_Button_Purple_clicked();
    else if(color == COLORS::COLOR_Yellow)
        on_Button_Yellow_clicked();
    else if(color == COLORS::COLOR_Brown)
        on_Button_Brown_clicked();
}

void ColorWidget::on_Button_Black_clicked()
{
    color = COLORS::COLOR_Black;

    ui->Button_Black->setStyleSheet("border-image: url(:/Color/Resource/Color_Black_Big.png);");
    ui->Button_Gray->setStyleSheet("border-image: url(:/Color/Resource/Color_Gray_Small.png);");
    ui->Button_Green->setStyleSheet("border-image: url(:/Color/Resource/Color_Green_Small.png);");
    ui->Button_Red->setStyleSheet("border-image: url(:/Color/Resource/Color_Red_Small.png);");
    ui->Button_Orangle->setStyleSheet("border-image: url(:/Color/Resource/Color_Orangle_Small.png);");
    ui->Button_White->setStyleSheet("border-image: url(:/Color/Resource/Color_White_Small.png);");
    ui->Button_Blue->setStyleSheet("border-image: url(:/Color/Resource/Color_Blue_Small.png);");
    ui->Button_Purple->setStyleSheet("border-image: url(:/Color/Resource/Color_Purple_Small.png);");
    ui->Button_Yellow->setStyleSheet("border-image: url(:/Color/Resource/Color_Yellow_Small.png);");
    ui->Button_Brown->setStyleSheet("border-image: url(:/Color/Resource/Color_Brown_Small.png);");

    emit ColorChange();
}

void ColorWidget::on_Button_Gray_clicked()
{
    color = COLORS::COLOR_Gray;

    ui->Button_Black->setStyleSheet("border-image: url(:/Color/Resource/Color_Black_Small.png);");
    ui->Button_Gray->setStyleSheet("border-image: url(:/Color/Resource/Color_Gray_Big.png);");
    ui->Button_Green->setStyleSheet("border-image: url(:/Color/Resource/Color_Green_Small.png);");
    ui->Button_Red->setStyleSheet("border-image: url(:/Color/Resource/Color_Red_Small.png);");
    ui->Button_Orangle->setStyleSheet("border-image: url(:/Color/Resource/Color_Orangle_Small.png);");
    ui->Button_White->setStyleSheet("border-image: url(:/Color/Resource/Color_White_Small.png);");
    ui->Button_Blue->setStyleSheet("border-image: url(:/Color/Resource/Color_Blue_Small.png);");
    ui->Button_Purple->setStyleSheet("border-image: url(:/Color/Resource/Color_Purple_Small.png);");
    ui->Button_Yellow->setStyleSheet("border-image: url(:/Color/Resource/Color_Yellow_Small.png);");
    ui->Button_Brown->setStyleSheet("border-image: url(:/Color/Resource/Color_Brown_Small.png);");

    emit ColorChange();
}

void ColorWidget::on_Button_Green_clicked()
{
    color = COLORS::COLOR_Green;

    ui->Button_Black->setStyleSheet("border-image: url(:/Color/Resource/Color_Black_Small.png);");
    ui->Button_Gray->setStyleSheet("border-image: url(:/Color/Resource/Color_Gray_Small.png);");
    ui->Button_Green->setStyleSheet("border-image: url(:/Color/Resource/Color_Green_Big.png);");
    ui->Button_Red->setStyleSheet("border-image: url(:/Color/Resource/Color_Red_Small.png);");
    ui->Button_Orangle->setStyleSheet("border-image: url(:/Color/Resource/Color_Orangle_Small.png);");
    ui->Button_White->setStyleSheet("border-image: url(:/Color/Resource/Color_White_Small.png);");
    ui->Button_Blue->setStyleSheet("border-image: url(:/Color/Resource/Color_Blue_Small.png);");
    ui->Button_Purple->setStyleSheet("border-image: url(:/Color/Resource/Color_Purple_Small.png);");
    ui->Button_Yellow->setStyleSheet("border-image: url(:/Color/Resource/Color_Yellow_Small.png);");
    ui->Button_Brown->setStyleSheet("border-image: url(:/Color/Resource/Color_Brown_Small.png);");

    emit ColorChange();
}

void ColorWidget::on_Button_Red_clicked()
{
    color = COLORS::COLOR_Red;

    ui->Button_Black->setStyleSheet("border-image: url(:/Color/Resource/Color_Black_Small.png);");
    ui->Button_Gray->setStyleSheet("border-image: url(:/Color/Resource/Color_Gray_Small.png);");
    ui->Button_Green->setStyleSheet("border-image: url(:/Color/Resource/Color_Green_Small.png);");
    ui->Button_Red->setStyleSheet("border-image: url(:/Color/Resource/Color_Red_Big.png);");
    ui->Button_Orangle->setStyleSheet("border-image: url(:/Color/Resource/Color_Orangle_Small.png);");
    ui->Button_White->setStyleSheet("border-image: url(:/Color/Resource/Color_White_Small.png);");
    ui->Button_Blue->setStyleSheet("border-image: url(:/Color/Resource/Color_Blue_Small.png);");
    ui->Button_Purple->setStyleSheet("border-image: url(:/Color/Resource/Color_Purple_Small.png);");
    ui->Button_Yellow->setStyleSheet("border-image: url(:/Color/Resource/Color_Yellow_Small.png);");
    ui->Button_Brown->setStyleSheet("border-image: url(:/Color/Resource/Color_Brown_Small.png);");

    emit ColorChange();
}

void ColorWidget::on_Button_Orangle_clicked()
{
    color = COLORS::COLOR_Orangle;

    ui->Button_Black->setStyleSheet("border-image: url(:/Color/Resource/Color_Black_Small.png);");
    ui->Button_Gray->setStyleSheet("border-image: url(:/Color/Resource/Color_Gray_Small.png);");
    ui->Button_Green->setStyleSheet("border-image: url(:/Color/Resource/Color_Green_Small.png);");
    ui->Button_Red->setStyleSheet("border-image: url(:/Color/Resource/Color_Red_Small.png);");
    ui->Button_Orangle->setStyleSheet("border-image: url(:/Color/Resource/Color_Orangle_Big.png);");
    ui->Button_White->setStyleSheet("border-image: url(:/Color/Resource/Color_White_Small.png);");
    ui->Button_Blue->setStyleSheet("border-image: url(:/Color/Resource/Color_Blue_Small.png);");
    ui->Button_Purple->setStyleSheet("border-image: url(:/Color/Resource/Color_Purple_Small.png);");
    ui->Button_Yellow->setStyleSheet("border-image: url(:/Color/Resource/Color_Yellow_Small.png);");
    ui->Button_Brown->setStyleSheet("border-image: url(:/Color/Resource/Color_Brown_Small.png);");

    emit ColorChange();
}

void ColorWidget::on_Button_White_clicked()
{
    color = COLORS::COLOR_White;

    ui->Button_Black->setStyleSheet("border-image: url(:/Color/Resource/Color_Black_Small.png);");
    ui->Button_Gray->setStyleSheet("border-image: url(:/Color/Resource/Color_Gray_Small.png);");
    ui->Button_Green->setStyleSheet("border-image: url(:/Color/Resource/Color_Green_Small.png);");
    ui->Button_Red->setStyleSheet("border-image: url(:/Color/Resource/Color_Red_Small.png);");
    ui->Button_Orangle->setStyleSheet("border-image: url(:/Color/Resource/Color_Orangle_Small.png);");
    ui->Button_White->setStyleSheet("border-image: url(:/Color/Resource/Color_White_Big.png);");
    ui->Button_Blue->setStyleSheet("border-image: url(:/Color/Resource/Color_Blue_Small.png);");
    ui->Button_Purple->setStyleSheet("border-image: url(:/Color/Resource/Color_Purple_Small.png);");
    ui->Button_Yellow->setStyleSheet("border-image: url(:/Color/Resource/Color_Yellow_Small.png);");
    ui->Button_Brown->setStyleSheet("border-image: url(:/Color/Resource/Color_Brown_Small.png);");

    emit ColorChange();
}

void ColorWidget::on_Button_Blue_clicked()
{
    color = COLORS::COLOR_Blue;

    ui->Button_Black->setStyleSheet("border-image: url(:/Color/Resource/Color_Black_Small.png);");
    ui->Button_Gray->setStyleSheet("border-image: url(:/Color/Resource/Color_Gray_Small.png);");
    ui->Button_Green->setStyleSheet("border-image: url(:/Color/Resource/Color_Green_Small.png);");
    ui->Button_Red->setStyleSheet("border-image: url(:/Color/Resource/Color_Red_Small.png);");
    ui->Button_Orangle->setStyleSheet("border-image: url(:/Color/Resource/Color_Orangle_Small.png);");
    ui->Button_White->setStyleSheet("border-image: url(:/Color/Resource/Color_White_Small.png);");
    ui->Button_Blue->setStyleSheet("border-image: url(:/Color/Resource/Color_Blue_Big.png);");
    ui->Button_Purple->setStyleSheet("border-image: url(:/Color/Resource/Color_Purple_Small.png);");
    ui->Button_Yellow->setStyleSheet("border-image: url(:/Color/Resource/Color_Yellow_Small.png);");
    ui->Button_Brown->setStyleSheet("border-image: url(:/Color/Resource/Color_Brown_Small.png);");

    emit ColorChange();
}

void ColorWidget::on_Button_Purple_clicked()
{
    color = COLORS::COLOR_Purple;

    ui->Button_Black->setStyleSheet("border-image: url(:/Color/Resource/Color_Black_Small.png);");
    ui->Button_Gray->setStyleSheet("border-image: url(:/Color/Resource/Color_Gray_Small.png);");
    ui->Button_Green->setStyleSheet("border-image: url(:/Color/Resource/Color_Green_Small.png);");
    ui->Button_Red->setStyleSheet("border-image: url(:/Color/Resource/Color_Red_Small.png);");
    ui->Button_Orangle->setStyleSheet("border-image: url(:/Color/Resource/Color_Orangle_Small.png);");
    ui->Button_White->setStyleSheet("border-image: url(:/Color/Resource/Color_White_Small.png);");
    ui->Button_Blue->setStyleSheet("border-image: url(:/Color/Resource/Color_Blue_Small.png);");
    ui->Button_Purple->setStyleSheet("border-image: url(:/Color/Resource/Color_Purple_Big.png);");
    ui->Button_Yellow->setStyleSheet("border-image: url(:/Color/Resource/Color_Yellow_Small.png);");
    ui->Button_Brown->setStyleSheet("border-image: url(:/Color/Resource/Color_Brown_Small.png);");

    emit ColorChange();
}

void ColorWidget::on_Button_Yellow_clicked()
{
    color = COLORS::COLOR_Yellow;

    ui->Button_Black->setStyleSheet("border-image: url(:/Color/Resource/Color_Black_Small.png);");
    ui->Button_Gray->setStyleSheet("border-image: url(:/Color/Resource/Color_Gray_Small.png);");
    ui->Button_Green->setStyleSheet("border-image: url(:/Color/Resource/Color_Green_Small.png);");
    ui->Button_Red->setStyleSheet("border-image: url(:/Color/Resource/Color_Red_Small.png);");
    ui->Button_Orangle->setStyleSheet("border-image: url(:/Color/Resource/Color_Orangle_Small.png);");
    ui->Button_White->setStyleSheet("border-image: url(:/Color/Resource/Color_White_Small.png);");
    ui->Button_Blue->setStyleSheet("border-image: url(:/Color/Resource/Color_Blue_Small.png);");
    ui->Button_Purple->setStyleSheet("border-image: url(:/Color/Resource/Color_Purple_Small.png);");
    ui->Button_Yellow->setStyleSheet("border-image: url(:/Color/Resource/Color_Yellow_Big.png);");
    ui->Button_Brown->setStyleSheet("border-image: url(:/Color/Resource/Color_Brown_Small.png);");

    emit ColorChange();
}

void ColorWidget::on_Button_Brown_clicked()
{
    color = COLORS::COLOR_Brown;

    ui->Button_Black->setStyleSheet("border-image: url(:/Color/Resource/Color_Black_Small.png);");
    ui->Button_Gray->setStyleSheet("border-image: url(:/Color/Resource/Color_Gray_Small.png);");
    ui->Button_Green->setStyleSheet("border-image: url(:/Color/Resource/Color_Green_Small.png);");
    ui->Button_Red->setStyleSheet("border-image: url(:/Color/Resource/Color_Red_Small.png);");
    ui->Button_Orangle->setStyleSheet("border-image: url(:/Color/Resource/Color_Orangle_Small.png);");
    ui->Button_White->setStyleSheet("border-image: url(:/Color/Resource/Color_White_Small.png);");
    ui->Button_Blue->setStyleSheet("border-image: url(:/Color/Resource/Color_Blue_Small.png);");
    ui->Button_Purple->setStyleSheet("border-image: url(:/Color/Resource/Color_Purple_Small.png);");
    ui->Button_Yellow->setStyleSheet("border-image: url(:/Color/Resource/Color_Yellow_Small.png);");
    ui->Button_Brown->setStyleSheet("border-image: url(:/Color/Resource/Color_Brown_Big.png);");

    emit ColorChange();
}
